package thread;

public class Demo05 {
    public static void main(String[] args) {
        //lamda表达式创建线程对象
        Thread t = new Thread(()->{
            while(true){
                System.out.println("hello thread");
                try {
                    //休眠500毫秒
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        //启动线程
        t.start();

        //主线程执行的任务
        while(true){
            System.out.println("hello main");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
